//一组函数，方法操作的库。原始js库。
var _ = require('underscore')
var Movie = require('../models/movie')
var Comment = require('../models/comment')
var Catetory = require('../models/catetory')

//admin post movie
exports.save = function(req,res){
	var _catetory = req.body.catetory;
	var catetory = new Catetory(_catetory);

	catetory.save(function(err,catetory){
		if(err){
			console.log(err);
		}
		res.redirect('/admin/catetory/list');
	})
}

//admin
exports.new = function(req,res){
	res.render('catetory_admin',{
		title:'imooc 分类录入页',
	})
}

//list
exports.list = function(req,res){
	Catetory.fetch(function(err,catetory){
		if(err){
			console.log(err);
		}
		res.render('catetory_list',{
			title:'imooc 分类列表页',
			catetories:catetory
		})
	});
}
